﻿using gt.webapi.core.Repositories;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Filters;

namespace gt.webapi.core.Filters.Authority
{
    public abstract class AuthenticationFilterBase : IAuthenticationFilter
    {
        protected IAuthorityRepository m_authorityRepository = null;
        protected bool m_allowMultiple = false;
        public AuthenticationFilterBase(IAuthorityRepository authorityRepository, bool allowMultiple = false)
        {
            this.m_authorityRepository = authorityRepository ?? throw new ArgumentNullException("authorityRepository");
            this.m_allowMultiple = allowMultiple;
        }
        public bool AllowMultiple => this.m_allowMultiple;

        public abstract Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken);
        public abstract Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken);
    }
}
